﻿
<!--********************* Part1:Jsp Head *********************-->

<%@ page contentType="text/html;charset=UTF-8"%>  
<%@ include file="/framework/head.jsp"%>

<!--********************* Part2:Java Code *********************-->
<%
    User user = (User)context.getSessionValue("UserDetail");
    ObjectList userMenuinfoList = (ObjectList)context.getSessionValue("UserMenuinfoList");
    ObjectList menuInfoHeadList = (ObjectList)context.getSessionValue("MenuInfoHeadList");
%>

<!--********************* Part3:JavaScript Code ***************-->
<script language="javascript">

function setCheckBoxs(i) {
    var obj = document.getElementById("HeadId" + i);
    if (obj.checked)
    {
        //全选
        setCheckBoxsFull("MenuId" +i);
    }
    else
    {
        //全消
        setCheckBoxsLess("MenuId" +i);
    }
}



function setCheckBoxsFull(name) {
    selectAllCheckBox(name);/*
    var objs = document.getElementById(name);
    alert(objs.length+"---------");
    for(var i=0; i<objs.length; i++) {
        if(objs[i].type.toLowerCase() == "checkbox" )
        objs[i].checked = true;
    }
    */
}


function setCheckBoxsLess(name) {
    unselectAllCheckBox(name);
    /*
    var objs = document.getElementById(name);
    for(var i=0; i<objs.length; i++) {
        if(objs[i].type.toLowerCase() == "checkbox" )
        objs[i].checked = false;
    }*/
}


function doSave()
{
	SetAction("saveUserFuncSet");
	frm.submit();
}
function doCancel()
{
	SetAction("backListUser");
	frm.submit();
}

key_InitDefault();
key_RegSubmitHandler(doSave);
</script>

<%=uiBody%>>

<%@ include file="/framework/menu.jsp"%>

<!--********************* Part4:Form  ***************-->

<form id=frm action="<%=Config.getSrv()%>" method="post">
<input type=hidden name="action_code">
<input type=hidden name="userId" value="<%=user.getId()%>">

<br>

<%=UIManager.addEditHeadTitle("操作员权限设置")%>


<!--********************* Part5:Edit Area  ***************-->
<%=uiEditStart%>>
<%
	int key_tab = 1 ;
%>

	<%=uiEditTR%>>
	  <%=uiEditTD%>>
         所属仓库：
        <%=user.getWarehouseName() %>（<%=user.getWarehouseCode() %>）
		<br>用&nbsp;户&nbsp;名：
        <%=user.getCode() %>
		<input type=hidden class="texts"  name="UserCode" size=20  value="<%=user.viewCode(con)%>" key_tab="<%=key_tab++%>">
		<br>姓&nbsp;&nbsp;&nbsp;&nbsp;名：
        <%=user.getName() %>
        <br>权限设置：
      </td>
    </tr>
    
<%
    for(int i=0;i<menuInfoHeadList.size();i++)
    {
        MenuInfo HeadId = (MenuInfo)menuInfoHeadList.get(i);        
        ObjectList menuInfoSubList = MenuInfo.fetchbyCode(HeadId.getMenuCode(),con);
%>
    <%=uiEditTR%>>
        <%=uiEditTD%>>
          <table width=600>
            <tr><td align=center colspan=3>
          <%=HeadId.viewMenuName(con) %>
          <input type=checkbox id="HeadId<%=i%>" name="HeadId<%=i%>" value="<%=i%>" <%=UserMenuinfo.IsExistHeadMenuBySubMenus(con,userMenuinfoList,HeadId.getMenuCode())?"checked":""%> onclick="setCheckBoxs(<%=i%>)">
          </td></tr>
          <%          
          for(int j=0;j<menuInfoSubList.size();j++)
          {
              if((j+1)%3 == 1) {%><tr><%}
              MenuInfo menuInfoSub = (MenuInfo)menuInfoSubList.get(j);
          %>
            <td><%=menuInfoSub.viewMenuName(con) %><input type=checkbox id="MenuId<%=i%>" name="MenuId" value="<%=menuInfoSub.getId() %>" <%=UserMenuinfo.IsExistBySubMenus(userMenuinfoList,menuInfoSub.getMenuCode())?"checked":"" %>>&nbsp;&nbsp;</td>
          
          <%
              if((j+1)%3 == 0) {%></tr><%}
          }
          %>
          
          </table>
        </td>
    </tr>
<%} %>	
<%=uiEditEnd%>

<!--********************* Part6:Action Area  ***************-->
<%=uiCommandStart%>>
	<%=uiCommandTR%>>
   		<%=uiCommandTD%>>
			<input type=button class="buttons" value="   保存   " onclick="doSave();return false;">
			<input type=button class="buttons" value="   返回   " onclick="doCancel();return false;">
		</td>
	</tr>
<%=uiCommandEnd%>
</form>

<%@ include file="/framework/foot.jsp"%>

<!--
	Author    :Wing
	FileName  :/system/base/UserFuncSet.jsp
-->
